<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_PilotLotdata extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_IdPILOTLOTDATA;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_PILOTLOADPLANIdPILOTLOADPLAN;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_PILOTPROJETANALYSEIdPILOTPROJETANALYSE;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_PILOTLOADPLANIdPILOTLOADPLAN1;


    /**
     * Parent relation fk_PILOT_LOTDATA_PILOT_PROJETANALYSE1
     *
     * @var Application_Model_PilotProjetanalyse
     */
    protected $_PilotProjetanalyse;

    /**
     * Parent relation fk_PILOT_LOTDATA_PILOT_LOADPLAN1
     *
     * @var Application_Model_PilotLoadplan
     */
    protected $_PilotLoadplan;


    /**
     * Dependent relation fk_PILOT_ENREGISTREMENT_PILOT_LOTDATA1
     * Type: One-to-Many relationship
     *
     * @var Application_Model_PilotEnregistrement
     */
    protected $_PilotEnregistrement;

    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idPILOT_LOTDATA'=>'IdPILOTLOTDATA',
            'PILOT_LOADPLAN_idPILOT_LOADPLAN'=>'PILOTLOADPLANIdPILOTLOADPLAN',
            'PILOT_PROJETANALYSE_idPILOT_PROJETANALYSE'=>'PILOTPROJETANALYSEIdPILOTPROJETANALYSE',
            'PILOT_LOADPLAN_idPILOT_LOADPLAN1'=>'PILOTLOADPLANIdPILOTLOADPLAN1',
        ));

        $this->setParentList(array(
            'FkPILOTLOTDATAPILOTPROJETANALYSE1'=> array(
                    'property' => 'PilotProjetanalyse',
                    'table_name' => 'PilotProjetanalyse',
                ),
            'FkPILOTLOTDATAPILOTLOADPLAN1'=> array(
                    'property' => 'PilotLoadplan',
                    'table_name' => 'PilotLoadplan',
                ),
        ));

        $this->setDependentList(array(
            'FkPILOTENREGISTREMENTPILOTLOTDATA1' => array(
                    'property' => 'PilotEnregistrement',
                    'table_name' => 'PilotEnregistrement',
                ),
        ));
    }

    /**
     * Sets column idPILOT_LOTDATA
     *
     * @param int $data
     * @return Application_Model_PilotLotdata
     */
    public function setIdPILOTLOTDATA($data)
    {
        $this->_IdPILOTLOTDATA = $data;
        return $this;
    }

    /**
     * Gets column idPILOT_LOTDATA
     *
     * @return int
     */
    public function getIdPILOTLOTDATA()
    {
        return $this->_IdPILOTLOTDATA;
    }

    /**
     * Sets column PILOT_LOADPLAN_idPILOT_LOADPLAN
     *
     * @param int $data
     * @return Application_Model_PilotLotdata
     */
    public function setPILOTLOADPLANIdPILOTLOADPLAN($data)
    {
        $this->_PILOTLOADPLANIdPILOTLOADPLAN = $data;
        return $this;
    }

    /**
     * Gets column PILOT_LOADPLAN_idPILOT_LOADPLAN
     *
     * @return int
     */
    public function getPILOTLOADPLANIdPILOTLOADPLAN()
    {
        return $this->_PILOTLOADPLANIdPILOTLOADPLAN;
    }

    /**
     * Sets column PILOT_PROJETANALYSE_idPILOT_PROJETANALYSE
     *
     * @param int $data
     * @return Application_Model_PilotLotdata
     */
    public function setPILOTPROJETANALYSEIdPILOTPROJETANALYSE($data)
    {
        $this->_PILOTPROJETANALYSEIdPILOTPROJETANALYSE = $data;
        return $this;
    }

    /**
     * Gets column PILOT_PROJETANALYSE_idPILOT_PROJETANALYSE
     *
     * @return int
     */
    public function getPILOTPROJETANALYSEIdPILOTPROJETANALYSE()
    {
        return $this->_PILOTPROJETANALYSEIdPILOTPROJETANALYSE;
    }

    /**
     * Sets column PILOT_LOADPLAN_idPILOT_LOADPLAN1
     *
     * @param int $data
     * @return Application_Model_PilotLotdata
     */
    public function setPILOTLOADPLANIdPILOTLOADPLAN1($data)
    {
        $this->_PILOTLOADPLANIdPILOTLOADPLAN1 = $data;
        return $this;
    }

    /**
     * Gets column PILOT_LOADPLAN_idPILOT_LOADPLAN1
     *
     * @return int
     */
    public function getPILOTLOADPLANIdPILOTLOADPLAN1()
    {
        return $this->_PILOTLOADPLANIdPILOTLOADPLAN1;
    }

    /**
     * Sets parent relation PILOTPROJETANALYSEIdPILOTPROJETANALYSE
     *
     * @param Application_Model_PilotProjetanalyse $data
     * @return Application_Model_PilotLotdata
     */
    public function setPilotProjetanalyse(Application_Model_PilotProjetanalyse $data)
    {
        $this->_PilotProjetanalyse = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idPILOT_PROJETANALYSE'];
        }

        $this->setPILOTPROJETANALYSEIdPILOTPROJETANALYSE($primary_key);

        return $this;
    }

    /**
     * Gets parent PILOTPROJETANALYSEIdPILOTPROJETANALYSE
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_PilotProjetanalyse
     */
    public function getPilotProjetanalyse($load = true)
    {
        if ($this->_PilotProjetanalyse === null && $load) {
            $this->getMapper()->loadRelated('FkPILOTLOTDATAPILOTPROJETANALYSE1', $this);
        }

        return $this->_PilotProjetanalyse;
    }

    /**
     * Sets parent relation PILOTLOADPLANIdPILOTLOADPLAN1
     *
     * @param Application_Model_PilotLoadplan $data
     * @return Application_Model_PilotLotdata
     */
    public function setPilotLoadplan(Application_Model_PilotLoadplan $data)
    {
        $this->_PilotLoadplan = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idPILOT_LOADPLAN'];
        }

        $this->setPILOTLOADPLANIdPILOTLOADPLAN1($primary_key);

        return $this;
    }

    /**
     * Gets parent PILOTLOADPLANIdPILOTLOADPLAN1
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_PilotLoadplan
     */
    public function getPilotLoadplan($load = true)
    {
        if ($this->_PilotLoadplan === null && $load) {
            $this->getMapper()->loadRelated('FkPILOTLOTDATAPILOTLOADPLAN1', $this);
        }

        return $this->_PilotLoadplan;
    }

    /**
     * Sets dependent relations fk_PILOT_ENREGISTREMENT_PILOT_LOTDATA1
     *
     * @param array $data An array of Application_Model_PilotEnregistrement
     * @return Application_Model_PilotLotdata
     */
    public function setPilotEnregistrement(array $data)
    {
        $this->_PilotEnregistrement = array();

        foreach ($data as $object) {
            $this->addPilotEnregistrement($object);
        }

        return $this;
    }

    /**
     * Sets dependent relations fk_PILOT_ENREGISTREMENT_PILOT_LOTDATA1
     *
     * @param Application_Model_PilotEnregistrement $data
     * @return Application_Model_PilotLotdata
     */
    public function addPilotEnregistrement(Application_Model_PilotEnregistrement $data)
    {
        $this->_PilotEnregistrement[] = $data;
        return $this;
    }

    /**
     * Gets dependent fk_PILOT_ENREGISTREMENT_PILOT_LOTDATA1
     *
     * @param boolean $load Load the object if it is not already
     * @return array The array of Application_Model_PilotEnregistrement
     */
    public function getPilotEnregistrement($load = true)
    {
        if ($this->_PilotEnregistrement === null && $load) {
            $this->getMapper()->loadRelated('FkPILOTENREGISTREMENTPILOTLOTDATA1', $this);
        }

        return $this->_PilotEnregistrement;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_PilotLotdata
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_PilotLotdata());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_PilotLotdata::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdPILOTLOTDATA() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idPILOT_LOTDATA = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdPILOTLOTDATA()));
    }
}
